<?php
/**
 * @license http://www.gnu.org/licenses/lgpl.html LGPL
 * @author Harlan Iverson <h dot iverson at gmail dot com>
 * @copyright Copyright (c) 2006, Harlan Iverson.
 * @version $Id: test-faces-config.php 20 2006-08-01 05:54:40Z Harlan $
 */
 
 
 

require_once( "TestHarness.php" );

class FacesConfigTest extends PhpUnit2_Framework_TestCase {

	var $facesConfig;

	function __construct($name) {
		parent::__construct($name);
	}
	
	function setUp() {
		$this->facesConfig = new PhpFaces_Config_FacesConfig();
	}
	
	function testParseOneFile() {
		$this->facesConfig->parse( PhpFaces_InstallationDir."base-config.xml" );
	}
	
	function testParseTwoFiles() {
		$this->facesConfig->parse( PhpFaces_InstallationDir."base-config.xml" );
		$this->facesConfig->parse( PhpFaces_TestDir."configs/test-faces-config.xml" );
		
		
	}
	
	function testComponentEntries() {
		$this->parseNeededConfigs();
		
		$ces = $this->facesConfig->getComponentEntries();
		
		$this->assertNotNull( $ces );
		$this->assertEquals( 14, count( $ces ) );
		
		foreach( $ces as $elem ) {
			$this->assertTrue( $elem instanceof PhpFaces_Config_ComponentEntry );
			$this->assertNotNull( $elem->type );
			$this->assertNotNull( $elem->class );
		}
		
	}
	
	function testManagedBeanEntries() {
		$this->parseNeededConfigs();
		$mbes = $this->facesConfig->getManagedBeans();
		
		$this->assertNotNull( $mbes );
		$this->assertEquals( 2, count( $mbes ) );
		
		foreach( $mbes as $elem ) {
			$this->assertTrue( $elem instanceof PhpFaces_Config_ManagedBeanConfigEntry );
			
		}
	}
	
	// this is run after the test parsing is done
	private function parseNeededConfigs() {
		$this->facesConfig->parse( PhpFaces_InstallationDir."base-config.xml" );
		$this->facesConfig->parse( PhpFaces_TestDir."configs/test-faces-config.xml" );
	}

}



?>
